<?php 
	session_start(); 
	include('user_type/system.php');
	include('access/login_functions.php');
	include("access/opendb.php"); 
	$_SESSION['restricted'] = true;
	check_logged_in();	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
		<meta name="keywords" content="KEYWORDS HERE!!!!">
		<meta name="description" content="Descrition Here!!!">
 
	<link rel="stylesheet" type="text/css" href="style_1.css">
	
	<!--[if lt IE 8]>
	<link rel="stylesheet" type="text/css" href="css.php?styleid=7&amp;langid=2&amp;d=1297275280&amp;td=ltr&amp;sheet=popupmenu-ie.css,vbulletin-ie.css,vbulletin-chrome-ie.css,vbulletin-formcontrols-ie.css,editor-ie.css" />
	<![endif]-->
</head>
<body>


<div class="above_body"> <!-- closing tag is in template navbar -->
<div id="header" class="floatcontainer doc_header">
	<div><a name="top" href="home.php" class="logo-image"><img src="images\QUESTwtrl2.png"  title=""></a></div>
	<div id="toplinks" class="toplinks">
		
			<ul class="nouser">
			<!--
				<?php if (!isset($_SESSION['user'])) echo "<li><a href=\"register.php\" rel=\"nofollow\">Register</a></li>"; ?>
			-->
				<li>
						<form id="navbar_loginform" action="access/login.php" method="post" >
					<input type="hidden" name="currentPage" value="<?php echo System::curPageName(); ?>" />
						<fieldset id="logindetails" class="logindetails">
							<div>
								<div>

							<?php // check if user is logged in
							if(isset($_SESSION['user']))
							{	$user = $_SESSION['user'];
								$_SESSION['curPage'] = System::curPageName(); 
								// if so, display username with tools
								echo "<div style=\"font-size: 16px; font-weight: bold;\">";
								echo "Welcome, $user <br />";
								echo "<a href=\"access/logout.php\">Log Out</a>";
								echo "<a href=\"userTools.php\">myTools</a>";
								echo "<a href=\"userInfo.php\">myProfile</a>";
								
								echo "</div>";
							}
							else
							{	// otherwise, display login form
								echo "<input type=\"text\" class=\"textbox default-value\" name=\"user\" id=\"navbar_username\" size=\"10\" tabindex=\"101\" value=\"Username\"> ";
								echo "<input type=\"password\" class=\"textbox default-value\" tabindex=\"102\" name=\"pass\" id=\"navbar_password_hint\" size=\"10\" value=\"Password\" style=\"display: inline; \"> ";
								echo "<input type=\"submit\" class=\"loginbutton\" tabindex=\"104\" value=\"Log in\" title=\"Enter your username and password in the boxes provided to login.\" accesskey=\"s\">";
							}
						?>
					</form>
				</li>
			</ul>
		
	</div>
	<div class="ad_global_header">
		 
		 
	</div>
	<hr>
</div> 


</div><!-- closing div for above_body -->

<div id="NewModerator" class="vbform block">

<h2 class="blockhead">View Complaints</h2>
	<div class="blockbody formcontrols">
		<div class="section">
			<?php
				$noComplaints = true;
				$result = mysql_query("SELECT * FROM complaint_table WHERE resolved='no'");
				if ($result)
				{
					while ($complaints = mysql_fetch_array($result))
					{
						$noComplaints = false;
						$complaint	= $complaints['complaint'];
						$filetype	= $complaints['type'];
						$fromUID	= intval($complaints['fromUID']);
						$toUID		= intval($complaints['toUID']);
						$CID		= intval($complaints['CID']);
						$ID 		= intval($complaints['ID']);
							
						if (!empty($filetype))
						{	$filetype .= "s_table";
							// go to appropriate content table to get filename
							$query1 = mysql_query("SELECT * FROM $filetype WHERE CID=$CID");
							if ($query1)
							{
								$entry1 = mysql_fetch_array($query1);
								$filename = $entry['Filename'];
							}
						}
						else
						{
							$filetype = "N/A";
							$filename = "N/A";
						}
						
						// go to user table to get usernames
						$query2 = mysql_query("SELECT * FROM user_table WHERE UID=$fromUID");
						if ($query2)
						{
							$entry2 = mysql_fetch_array($query2);
							$fromUsername = $entry2['Username'];
							mysql_free_result($query2);
						}
						
						$query2 = mysql_query("SELECT * FROM user_table WHERE UID=$toUID");
						if ($query2)
						{
							$entry2 = mysql_fetch_array($query2);
							$toUsername = $entry2['Username'];
							mysql_free_result($query2);
						}
						
						echo "<form action=\"process/processModeratorComplaintDecision.php\" method=\"post\">\n";
						echo "<input type=\"hidden\" name=\"toUID\"  value=\"$toUID\" />\n";
						echo "<input type=\"hidden\" name=\"fromUID\"  value=\"$fromUID\" />\n";
						echo "<input type=\"hidden\" name=\"complaint\"  value=\"$complaint\" />\n";
						echo "<input type=\"hidden\" name=\"complaintID\" value=\"$ID\" />\n";
						echo "<div class=\"blockrow\">\n";
						echo "<ul class=\"group\">\n";
						echo "<li>Name: $filename</li>\n";
						echo "<li>Type: $filetype</li>\n";
						echo "<li>Complaint From: $fromUsername</li>\n";
						echo "<li>Complaint Directed Towards: $toUsername</li>\n";
						echo "<li>Complaint: $complaint</li>\n";
						echo "<li>\n";
						

						echo "<input type=\"submit\" class=\"button\" name=\"decision\" value=\"Honor Complaint\">";
						echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
						echo "<input type=\"submit\" class=\"button\" name=\"decision\" value=\"Deny Complaint\">\n";
						echo "</li>\n";
						echo "</ul>\n";
						echo "</div>\n";
						echo "</form>\n\n";
					}
				}
				
				if ($noComplaints)
				{
					echo "<div class=\"blockrow\">\n";
					echo "There are no more complaints!\n";
					echo "</div>\n";
				}
			?>
		</div>
	</div>
	
</div>

 </body></html>